package com.neuedu.web.dao;

import com.neuedu.web.common.BaseDao;
import com.neuedu.web.po.DeptPO;
import com.neuedu.web.po.UserRolePO;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * @author 金山
 * 项目：jdbc-dao
 * site: https://blog.fulfill.com.cn
 * 描述  dept 表的数据访问对象
 * @data  2024年11月21日13:38:03
 */
public class UserRoleDao extends BaseDao<UserRolePO> {



    public List<UserRolePO> selectAll(  String sql, Object... params) throws NoSuchFieldException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        return super.selectAll(UserRolePO.class , sql,params);
    }
    // public List<DeptPO> selectPage( int current, int size, String sql, Object... params) throws NoSuchFieldException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
    //     return super.selectPage(DeptPO.class , current ,size,sql,params);
    // }



    // public DeptPO selectById(long id) throws NoSuchFieldException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
    //
    //
    //     String sql = "select * from dept where dept_id= ?";
    //     return super.selectOne(DeptPO.class,sql,id);
    //
    // }



    public int insert(UserRolePO userRole) {
        String sql = "INSERT INTO `user_role` (   `userid`, `role_id`) VALUES(  ?,? )  ";
        int count = super.update(sql,
                userRole.getUserid(),
                userRole.getRoleId()
        );

        return count;

    }


    /**
     * 根据用户 id 删除已经授权的橘色
     * @param userid
     * @return
     */
    public int deleteByUserId(String userid) {
        String sql = "delete from  `user_role`  where  userid = ? ";
        int count = super.update(sql,userid );

        return count;
    }


    // public int update(DeptPO dept) {
    //     StringBuffer sql = new StringBuffer();
    //
    //     sql.append(" update 					");
    //     sql.append("   `dept` 			");
    //     sql.append(" set			");
    //     sql.append("   `dept_name` = ?,			");
    //     sql.append("   `loc` = ?,			");
    //     sql.append("   `leader` = ?			");
    //
    //     sql.append(" where `dept_id` =  ?			");
    //
    //
    //     int count = super.update(sql.toString(),
    //             dept.getDeptName(),
    //             dept.getLoc(),
    //             dept.getLeader(),
    //             dept.getDeptId()
    //     );
    //
    //     return count;
    //
    // }

    /**
     * 通用的方法
     *
     * @return
     */

    // public int delete(long id) {
    //     StringBuffer sql = new StringBuffer();
    //
    //     sql.append(" delete from dept where dept_id = ?");
    //
    //     int count = super.update(sql.toString(),   id        );
    //
    //     return count;
    //
    // }


}
